package dk
{
	import flash.media.Camera;
	import mx.controls.VideoDisplay;

	public class WebCamDisplaySimple extends VideoDisplay
	{
 		/*  public function WebCamDisplaySimple()
		{
			super();
		} 
		 */
		
		private var cameraNameChanged:Boolean = true;
		
		private var _cameraName:String;
		
		[Bindable]
		public function set cameraName(value:String):void {
			_cameraName = value;
		
			cameraNameChanged = true;
			invalidateProperties();
		}
		
		public function get cameraName():String {
			return _cameraName;
		}
		
		[Bindable]
		public var camera:Camera;
		
		override protected function commitProperties():void {
			super.commitProperties();
			
			if(cameraNameChanged) {
				camera = Camera.getCamera(_cameraName);
   				
   				if(camera) {
   					attachCamera(camera);
   				}
   		
   				cameraNameChanged = false;
			}
		}
		
		override protected function measure():void {
			super.measure();
			
			measuredHeight = camera.height;
			measuredWidth = camera.width;
		}
		
	}
}